package com.jbit.dm212.config;

import com.jbit.dm212.interceptor.UserInterceptor;
import org.apache.catalina.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInterceptor())
                .addPathPatterns("/**/api/v/**");
    }

    @Bean
    public UserInterceptor userInterceptor(){
        return new UserInterceptor();
    }
}
